<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="援外项目" prop="aidProjectTitle">
        <el-input
          v-model="queryParams.aidProjectTitle"
          placeholder="请输入援外项目标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="援外项目A" prop="aidProjectA">
        <el-input
          v-model="queryParams.aidProjectA"
          placeholder="请输入援外项目A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="援外项目B" prop="aidProjectB">
        <el-input
          v-model="queryParams.aidProjectB"
          placeholder="请输入援外项目B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="援外项目C" prop="aidProjectC">
        <el-input
          v-model="queryParams.aidProjectC"
          placeholder="请输入援外项目C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="援外项目D" prop="aidProjectD">
        <el-input
          v-model="queryParams.aidProjectD"
          placeholder="请输入援外项目D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创新项目标题" prop="innovationProjectTitle">
        <el-input
          v-model="queryParams.innovationProjectTitle"
          placeholder="请输入创新项目标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创新项目A" prop="innovationProjectA">
        <el-input
          v-model="queryParams.innovationProjectA"
          placeholder="请输入创新项目A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创新项目B" prop="innovationProjectB">
        <el-input
          v-model="queryParams.innovationProjectB"
          placeholder="请输入创新项目B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创新项目C" prop="innovationProjectC">
        <el-input
          v-model="queryParams.innovationProjectC"
          placeholder="请输入创新项目C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创新项目D" prop="innovationProjectD">
        <el-input
          v-model="queryParams.innovationProjectD"
          placeholder="请输入创新项目D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业项目标题" prop="industryProjectTitle">
        <el-input
          v-model="queryParams.industryProjectTitle"
          placeholder="请输入产业项目标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业项目A" prop="industryProjectA">
        <el-input
          v-model="queryParams.industryProjectA"
          placeholder="请输入产业项目A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业项目B" prop="industryProjectB">
        <el-input
          v-model="queryParams.industryProjectB"
          placeholder="请输入产业项目B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业项目C" prop="industryProjectC">
        <el-input
          v-model="queryParams.industryProjectC"
          placeholder="请输入产业项目C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业项目D" prop="industryProjectD">
        <el-input
          v-model="queryParams.industryProjectD"
          placeholder="请输入产业项目D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农产品标题" prop="agriculturalProductTitle">
        <el-input
          v-model="queryParams.agriculturalProductTitle"
          placeholder="请输入农产品标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农产品A" prop="agriculturalProductA">
        <el-input
          v-model="queryParams.agriculturalProductA"
          placeholder="请输入农产品A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农产品B" prop="agriculturalProductB">
        <el-input
          v-model="queryParams.agriculturalProductB"
          placeholder="请输入农产品B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农产品C" prop="agriculturalProductC">
        <el-input
          v-model="queryParams.agriculturalProductC"
          placeholder="请输入农产品C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农产品D" prop="agriculturalProductD">
        <el-input
          v-model="queryParams.agriculturalProductD"
          placeholder="请输入农产品D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dash:projects:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['dash:projects:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dash:projects:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dash:projects:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="projectsList" @selection-change="handleSelectionChange" >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="项目标题" align="center" prop="aidProjectTitle" show-overflow-tooltip/>
      <el-table-column label="项目A" align="center" prop="aidProjectA" show-overflow-tooltip/>
      <el-table-column label="项目A图" align="center" prop="aidProjectAImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.aidProjectAImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="项目B" align="center" prop="aidProjectB" show-overflow-tooltip/>
      <el-table-column label="项目B图" align="center" prop="aidProjectBImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.aidProjectBImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="项目C" align="center" prop="aidProjectC" show-overflow-tooltip/>
      <el-table-column label="项目C图" align="center" prop="aidProjectCImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.aidProjectCImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="项目D" align="center" prop="aidProjectD" show-overflow-tooltip/>
      <el-table-column label="项目D图" align="center" prop="aidProjectDImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.aidProjectDImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="创新项目标题" align="center" prop="innovationProjectTitle" show-overflow-tooltip/>
      <el-table-column label="项目A" align="center" prop="innovationProjectA" />
      <el-table-column label="项目A图" align="center" prop="innovationProjectAImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.innovationProjectAImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="项目B" align="center" prop="innovationProjectB" show-overflow-tooltip/>
      <el-table-column label="项目B图" align="center" prop="innovationProjectBImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.innovationProjectBImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="项目C" align="center" prop="innovationProjectC" show-overflow-tooltip/>
      <el-table-column label="项目C图" align="center" prop="innovationProjectCImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.innovationProjectCImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="项目D" align="center" prop="innovationProjectD" show-overflow-tooltip/>
      <el-table-column label="项目D图" align="center" prop="innovationProjectDImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.innovationProjectDImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="产业项目标题" align="center" prop="industryProjectTitle" show-overflow-tooltip/>
      <el-table-column label="产业项目A" align="center" prop="industryProjectA" show-overflow-tooltip/>
      <el-table-column label="产业项目A图" align="center" prop="industryProjectAImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.industryProjectAImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="产业项目B" align="center" prop="industryProjectB" show-overflow-tooltip/>
      <el-table-column label="产业项目B图" align="center" prop="industryProjectBImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.industryProjectBImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="产业项目C" align="center" prop="industryProjectC" show-overflow-tooltip/>
      <el-table-column label="产业项目C图" align="center" prop="industryProjectCImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.industryProjectCImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="产业项目D" align="center" prop="industryProjectD" show-overflow-tooltip/>
      <el-table-column label="产业项目D图" align="center" prop="industryProjectDImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.industryProjectDImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="农产品标题" align="center" prop="agriculturalProductTitle" show-overflow-tooltip/>
      <el-table-column label="农产品A" align="center" prop="agriculturalProductA" show-overflow-tooltip/>
      <el-table-column label="农产品A图" align="center" prop="agriculturalProductAImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.agriculturalProductAImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="农产品B" align="center" prop="agriculturalProductB" show-overflow-tooltip/>
      <el-table-column label="农产品B图" align="center" prop="agriculturalProductBImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.agriculturalProductBImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="农产品C" align="center" prop="agriculturalProductC"show-overflow-tooltip />
      <el-table-column label="农产品C图" align="center" prop="agriculturalProductCImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.agriculturalProductCImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="农产品D" align="center" prop="agriculturalProductD" show-overflow-tooltip/>
      <el-table-column label="农产品D图" align="center" prop="agriculturalProductDImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.agriculturalProductDImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="宣传视频" align="center" prop="promotionVideoUrl" show-overflow-tooltip>
        <template slot-scope="scope">
        <!-- 显示"查看视频"按钮 -->
        <el-button
          v-if="scope.row.promotionVideoUrl"
          type="text"
          icon="el-icon-video-camera"
          @click="openVideo(scope.row.promotionVideoUrl)"
        >
          查看视频
        </el-button>
        <!-- 没有视频时显示 -->
        <span v-else>无</span>
      </template>
      </el-table-column>
      
      <el-table-column min-width="100px" label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['dash:projects:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dash:projects:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <video-column ref="videoPlayer"></video-column>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
  <el-form ref="form" :model="form" :rules="rules" label-width="80px">
    <!-- 第一组：援外项目 -->
    <el-divider content-position="left" style="color: #666; font-size: 14px;">援外项目</el-divider>
    <el-row :gutter="20">  
        <el-col :span="6">
          <el-form-item label="项目标题" prop="aidProjectTitle">
            <el-input v-model="form.aidProjectTitle" placeholder="请输入援外项目标题" width="220px" />
          </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
    
      <el-col :span="6">
        <el-form-item label="项目A" prop="aidProjectA">
          <el-input v-model="form.aidProjectA" placeholder="请输入援外项目A" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目A图片" prop="aidProjectAImg">
          <image-upload v-model="form.aidProjectAImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目B" prop="aidProjectB">
          <el-input v-model="form.aidProjectB" placeholder="请输入援外项目B" width="220px" />
        </el-form-item>
      </el-col>
       <el-col :span="6">
        <el-form-item label="项目B图片" prop="aidProjectBImg">
          <image-upload v-model="form.aidProjectBImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
     
      <el-col :span="6">
        <el-form-item label="项目C" prop="aidProjectC">
          <el-input v-model="form.aidProjectC" placeholder="请输入援外项目C" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目C图片" prop="aidProjectCImg">
          <image-upload v-model="form.aidProjectCImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目D" prop="aidProjectD">
          <el-input v-model="form.aidProjectD" placeholder="请输入援外项目D" width="220px" />
        </el-form-item>
      </el-col>
       <el-col :span="6">
        <el-form-item label="项目D图片" prop="aidProjectDImg">
          <image-upload v-model="form.aidProjectDImg"/>
        </el-form-item>
      </el-col>
    </el-row>



    <!-- 第二组：创新项目 -->
    <el-divider content-position="left" style="color: #666; font-size: 14px;">创新项目</el-divider>
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="项目标题" prop="innovationProjectTitle">
          <el-input v-model="form.innovationProjectTitle" placeholder="请输入创新项目标题" width="220px" />
        </el-form-item>
      </el-col>
    </el-row>
    
    <el-row :gutter="20">
     
      <el-col :span="6">
        <el-form-item label="项目A" prop="innovationProjectA">
          <el-input v-model="form.innovationProjectA" placeholder="请输入创新项目A" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目A图片" prop="innovationProjectAImg">
          <image-upload v-model="form.innovationProjectAImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目B" prop="innovationProjectB">
          <el-input v-model="form.innovationProjectB" placeholder="请输入创新项目B" width="220px" />
        </el-form-item>
      </el-col>
       <el-col :span="6">
        <el-form-item label="项目B图片" prop="innovationProjectBImg">
          <image-upload v-model="form.innovationProjectBImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="创新项目C" prop="innovationProjectC">
          <el-input v-model="form.innovationProjectC" placeholder="请输入创新项目C" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目C图片" prop="innovationProjectCImg">
          <image-upload v-model="form.innovationProjectCImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="创新项目D" prop="innovationProjectD">
          <el-input v-model="form.innovationProjectD" placeholder="请输入创新项目D" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目D图片" prop="innovationProjectDImg">
          <image-upload v-model="form.innovationProjectDImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <!-- 第三组：产业项目 -->
    <el-divider content-position="left" style="color: #666; font-size: 14px;">产业项目</el-divider>
    
    <el-row  :gutter="20">  
       <el-col :span="6">
        <el-form-item label="项目标题" prop="industryProjectTitle">
          <el-input v-model="form.industryProjectTitle" placeholder="请输入产业项目标题" width="220px" />
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="项目A" prop="industryProjectA">
          <el-input v-model="form.industryProjectA" placeholder="请输入产业项目A" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目A图片" prop="industryProjectAImg">
          <image-upload v-model="form.industryProjectAImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目B" prop="industryProjectB">
          <el-input v-model="form.industryProjectB" placeholder="请输入产业项目B" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目B图片" prop="industryProjectBImg">
          <image-upload v-model="form.industryProjectBImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="项目C" prop="industryProjectC">
          <el-input v-model="form.industryProjectC" placeholder="请输入产业项目C" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目C图片" prop="industryProjectCImg">
          <image-upload v-model="form.industryProjectCImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="产业项目D" prop="industryProjectD">
          <el-input v-model="form.industryProjectD" placeholder="请输入产业项目D" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="项目D图片" prop="industryProjectDImg">
          <image-upload v-model="form.industryProjectDImg"/>
        </el-form-item>
      </el-col>
    </el-row>


    <!-- 第四组：农产品项目 -->
    <el-divider content-position="left" style="color: #666; font-size: 14px;">农产品项目</el-divider>
    <el-row>
       <el-col :span="6">
        <el-form-item label="农产品标题" prop="agriculturalProductTitle">
          <el-input v-model="form.agriculturalProductTitle" placeholder="请输入农产品标题" width="220px" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
     
      <el-col :span="6">
        <el-form-item label="农产品A" prop="agriculturalProductA">
          <el-input v-model="form.agriculturalProductA" placeholder="请输入农产品A" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农产品A图片" prop="agriculturalProductAImg">
          <image-upload v-model="form.agriculturalProductAImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农产品B" prop="agriculturalProductB">
          <el-input v-model="form.agriculturalProductB" placeholder="请输入农产品B" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农产品B图片" prop="agriculturalProductBImg">
          <image-upload v-model="form.agriculturalProductBImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      
      <el-col :span="6">
        <el-form-item label="农产品C" prop="agriculturalProductC">
          <el-input v-model="form.agriculturalProductC" placeholder="请输入农产品C" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农产品C图片" prop="agriculturalProductCImg">
          <image-upload v-model="form.agriculturalProductCImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农产品D" prop="agriculturalProductD">
          <el-input v-model="form.agriculturalProductD" placeholder="请输入农产品D" width="220px" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农产品D图片" prop="agriculturalProductDImg">
          <image-upload v-model="form.agriculturalProductDImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="宣传视频" prop="promotionVideoUrl">
           <video-upload v-model="form.promotionVideoUrl" placeholder="请输入高标准农田宣传视频URL" />
        </el-form-item>
      </el-col>
      <!-- 空列占位 -->
      <el-col :span="6"></el-col>
      <el-col :span="6"></el-col>
    </el-row>
  </el-form>

  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitForm">确 定</el-button>
    <el-button @click="cancel">取 消</el-button>
  </div>
</el-dialog>

  </div>
</template>

<script>
import { listProjects, getProjects, delProjects, addProjects, updateProjects } from "@/api/dash/projects"

export default {
  name: "Projects",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 海外项目表格数据
      projectsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        aidProjectTitle: null,
        aidProjectA: null,
        aidProjectAImg: null,
        aidProjectB: null,
        aidProjectBImg: null,
        aidProjectC: null,
        aidProjectCImg: null,
        aidProjectD: null,
        aidProjectDImg: null,
        innovationProjectTitle: null,
        innovationProjectA: null,
        innovationProjectAImg: null,
        innovationProjectB: null,
        innovationProjectBImg: null,
        innovationProjectC: null,
        innovationProjectCImg: null,
        innovationProjectD: null,
        innovationProjectDImg: null,
        industryProjectTitle: null,
        industryProjectA: null,
        industryProjectAImg: null,
        industryProjectB: null,
        industryProjectBImg: null,
        industryProjectC: null,
        industryProjectCImg: null,
        industryProjectD: null,
        industryProjectDImg: null,
        agriculturalProductTitle: null,
        agriculturalProductA: null,
        agriculturalProductAImg: null,
        agriculturalProductB: null,
        agriculturalProductBImg: null,
        agriculturalProductC: null,
        agriculturalProductCImg: null,
        agriculturalProductD: null,
        agriculturalProductDImg: null,
        promotionVideoUrl: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        aidProjectTitle: [
          { required: true, message: "援外项目标题不能为空", trigger: "blur" }
        ],
        innovationProjectTitle: [
          { required: true, message: "创新项目标题不能为空", trigger: "blur" }
        ],
        industryProjectTitle: [
          { required: true, message: "产业项目标题不能为空", trigger: "blur" }
        ],
        agriculturalProductTitle: [
          { required: true, message: "农产品标题不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "修改时间不能为空", trigger: "blur" }
        ]
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    openVideo(url) {
      this.$refs.videoPlayer.openVideo(url)
    },
    /** 查询海外项目列表 */
    getList() {
      this.loading = true
      listProjects(this.queryParams).then(response => {
        this.projectsList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        aidProjectTitle: null,
        aidProjectA: null,
        aidProjectAImg: null,
        aidProjectB: null,
        aidProjectBImg: null,
        aidProjectC: null,
        aidProjectCImg: null,
        aidProjectD: null,
        aidProjectDImg: null,
        innovationProjectTitle: null,
        innovationProjectA: null,
        innovationProjectAImg: null,
        innovationProjectB: null,
        innovationProjectBImg: null,
        innovationProjectC: null,
        innovationProjectCImg: null,
        innovationProjectD: null,
        innovationProjectDImg: null,
        industryProjectTitle: null,
        industryProjectA: null,
        industryProjectAImg: null,
        industryProjectB: null,
        industryProjectBImg: null,
        industryProjectC: null,
        industryProjectCImg: null,
        industryProjectD: null,
        industryProjectDImg: null,
        agriculturalProductTitle: null,
        agriculturalProductA: null,
        agriculturalProductAImg: null,
        agriculturalProductB: null,
        agriculturalProductBImg: null,
        agriculturalProductC: null,
        agriculturalProductCImg: null,
        agriculturalProductD: null,
        agriculturalProductDImg: null,
        promotionVideoUrl: null,
        updateTime: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加海外项目"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getProjects(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改海外项目"
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateProjects(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addProjects(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除海外项目编号为"' + ids + '"的数据项？').then(function() {
        return delProjects(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dash/projects/export', {
        ...this.queryParams
      }, `projects_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
